/**
 * @name: core.ts
 * @author: XU>.<CHEN
 * @date: 2022-06-01 14:49
 * @description：core.ts
 * @update: 2022-06-01 14:49
 */
import { GetUserAuth } from '@/api/modules/loginApi'


export default {
  namespaced: true,
  state: {
    dynamicCreateRoute: false,
    routeAuth: [] // 用户路由表
  },
  getters: {

  },
  mutations: {
    updateDynamicCreateRoute: function(state: any, flag: Boolean) {
      state.dynamicCreateRoute = flag
    },
    setRouteAuth: function(state: any, routeAuth: Array<Object>) {
      state.routeAuth = routeAuth
    }
  },
  actions: {
    getRouteAuth({ commit, state }: any, userName: string) {
      return new Promise((resolve, reject) => {
        GetUserAuth().then(res => {
          commit('setRouteAuth', res)
          resolve(res)
        })
      })
    }
  }
}
